#include "labelbutton.h"
#include "globaldef.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>

LabelButton::LabelButton(QWidget *parent) : QPushButton(parent)
{
    initWidget();
}

QLabel *LabelButton::getNameLabelInstance()
{
    return name;
}

QLabel *LabelButton::getCodeLabelInstance()
{
    return code;
}

QHBoxLayout *LabelButton::getHLayoutInstance()
{
    return hLayout;
}

const QString LabelButton::getName()
{
    return name->text();
}

const QString LabelButton::getCode()
{
    return code->text();
}

void LabelButton::setName(const QString & _name)
{
    name->setText(_name);
}

void LabelButton::setCode(const QString & _code)
{
    code->setText(_code);
}

void LabelButton::initWidget()
{
    name = new QLabel(this);
    code = new QLabel(this);
    code->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    hLayout = new QHBoxLayout();
    hLayout->addWidget(name);
    hLayout->addWidget(code);
    hLayout->setMargin(windowWidth >= 1280 ? 20 : 12);
    hLayout->setSpacing(10);
    this->setLayout(hLayout);
}
